package main

import "fmt"

//26.翻转二维数组
//    翻转下面这个二维数组
//    a = [][]int{
//        {0, 1, 2, 3} ,
//        {4, 5, 6, 7} ,
//        {8, 9, 10, 11},
//    }

func main() {
	var a = [][]int{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}
	fmt.Println(a)

	//行与列互换
	row := len(a[0]) //arr的row，
	col := len(a)    //arr的col

	//定义一个反转数组的切片
	arr := make([][]int, row, row)
	for i := 0; i <= row-1; i++ {
		arr[i] = make([]int, col)
	}

	for k := col - 1; k >= 0; k-- {
		for y := row - 1; y >= 0; y-- {
			arr[y][k] = a[k][y]
		}
	}
	fmt.Println(arr)
}
